#pragma once #define _USE_MATH_DEFINES #include namespace Grafika { ... ... ... #pragma endregion int A, Okres; // -------------------------------------------------------------------------- private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { A=150; Okres=75; } // -------------------------------------------------------------------------- private: System::Void pictureBox1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) { Graphics^ grafika = e->Graphics; grafika->Clear( Color::White); Pen^ pioro=gcnew Pen(Color::Blue); if(checkBoxL->Checked==true) grafika->DrawLine(pioro, 10,10, 140,10); // Rysowanie linii SolidBrush^ pedz = gcnew SolidBrush(Color::LightGreen); if(checkBoxP->Checked==true) grafika->FillRectangle(pedz, 20,50, 120, 150); pioro->Width=6; pioro->Color=Color::Red; pioro->EndCap=Drawing2D::LineCap::ArrowAnchor; //NoAnchor //pioro->DashStyle = System::Drawing::Drawing2D::DashStyle::DashDotDot; int szerokosc=pictureBox1->Width; if(checkBoxS->Checked==true) grafika->DrawLine(pioro, 10,20, szerokosc-10,20); SolidBrush^ pedzel = gcnew SolidBrush(System::Drawing::Color::DarkGreen); System::Drawing::Font^ czcionka = gcnew System::Drawing::Font( System::Drawing::FontFamily::GenericSansSerif, 14, FontStyle::Regular); if(checkBoxN->Checked==true) grafika->DrawString("Ala ma kota",czcionka,pedzel,10,25); pioro->Color=Color::DarkRed; if(checkBoxE->Checked==true) grafika->DrawEllipse(pioro, 20,180, 200, 150); pioro->Color=Color::Yellow; if(checkBoxP->Checked==true) grafika->DrawRectangle(pioro, 40,80, szerokosc-80, 70); Pen^ pioro2=gcnew Pen(Color::Black); pioro2->Width=3; if(checkBoxKrzyzyk->Checked==true) { grafika->DrawLine(pioro2, 0,0, pictureBox1->Width,pictureBox1->Height); grafika->DrawLine(pioro2, 0,pictureBox1->Height, pictureBox1->Width,0); } if(checkBoxDom->Checked==true) { int szer=pictureBox1->Width,wys=pictureBox1->Height; grafika->DrawLine(pioro2, int(0.2*szer),int(0.5*wys), int(0.2*szer),int(0.8*wys)); grafika->DrawLine(pioro2, int(0.2*szer),int(0.8*wys), int(0.8*szer),int(0.8*wys)); grafika->DrawLine(pioro2, int(0.8*szer),int(0.8*wys), int(0.8*szer),int(0.5*wys)); grafika->DrawLine(pioro2, int(0.8*szer),int(0.5*wys), int(0.2*szer),int(0.5*wys)); grafika->DrawLine(pioro2, int(0.2*szer),int(0.5*wys), int(0.5*szer),int(0.2*wys)); grafika->DrawLine(pioro2, int(0.5*szer),int(0.2*wys), int(0.8*szer),int(0.5*wys)); } if(checkBoxSin->Checked==true) { pioro2->Width=1; int yp=200; for(int x=1; x< pictureBox1->Width; x++) { int y=200+A*sin(2*M_PI/Okres*x); grafika->DrawLine(pioro2, x-1,yp,x,y); yp=y; } } } // -------------------------------------------------------------------------- private: System::Void pictureBox1_Resize(System::Object^ sender, System::EventArgs^ e) { pictureBox1->Invalidate(); } // -------------------------------------------------------------------------- private: System::Void hScrollBar_Scroll(System::Object^ sender, System::Windows::Forms::ScrollEventArgs^ e) { A=hScrollBarA->Value; labelA->Text=L"A = "+hScrollBarA->Value.ToString(); Okres=hScrollBarOkres->Value; labelOkres->Text=L"O = "+Okres.ToString(); pictureBox1->Invalidate(); } // -------------------------------------------------------------------------- }; }